package com.skyolder.milkbee.service;

import com.skyolder.milkbee.domain.Requisition;
import com.skyolder.milkbee.repository.RequisitionRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;

import javax.inject.Inject;
import java.util.List;

/**
 * Service Implementation for managing Requisition.
 */
@Service
@Transactional
public class RequisitionService {

    private final Logger log = LoggerFactory.getLogger(RequisitionService.class);
    
    @Inject
    private RequisitionRepository requisitionRepository;

    /**
     * Save a requisition.
     *
     * @param requisition the entity to save
     * @return the persisted entity
     */
    public Requisition save(Requisition requisition) {
        log.debug("Request to save Requisition : {}", requisition);
        Requisition result = requisitionRepository.save(requisition);
        return result;
    }

    /**
     *  Get all the requisitions.
     *  
     *  @return the list of entities
     */
    @Transactional(readOnly = true) 
    public List<Requisition> findAll() {
        log.debug("Request to get all Requisitions");
        List<Requisition> result = requisitionRepository.findAll();

        return result;
    }

    /**
     *  Get one requisition by id.
     *
     *  @param id the id of the entity
     *  @return the entity
     */
    @Transactional(readOnly = true) 
    public Requisition findOne(Long id) {
        log.debug("Request to get Requisition : {}", id);
        Requisition requisition = requisitionRepository.findOne(id);
        return requisition;
    }

    /**
     *  Delete the  requisition by id.
     *
     *  @param id the id of the entity
     */
    public void delete(Long id) {
        log.debug("Request to delete Requisition : {}", id);
        requisitionRepository.delete(id);
    }
}
